<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第四题</title>
</head>

<body>
    <script>
        const arr = [
            { uname: '孙六', age: 39 },
            { uname: '刘七', age: 21 },
            { uname: '刘七', age: 1 },
            { uname: '张三', age: 59 },
            { uname: '李四', age: 29 },
            { uname: '王二', age: 19 },
        ]
        const arr1 = JSON.parse(JSON.stringify(arr))
        // console.log(arr1)
        function getArray(arr) {
            arr.map(function (item, index) {
                if (item.age % 10 === 9) {
                    // arr[index].age.replace(/9/, '*')
                    let shi = parseInt(item.age / 10)
                    arr[index].age = shi + `${String(item.age % 10).replace(/9/, '*')}`
                }
                if (item.uname === '张三') {
                    item.uname = '孙六',
                        item.age = `2*`
                }
                if (item.age < 18) {
                    arr.splice(index, 1)
                }
            })
            console.log(arr)
        }
        getArray(arr1)
    </script>
</body>

</html>